package com.heima.admin.controller;

import com.heima.api.INewsClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.NewsListDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
@Slf4j
public class AdminController {
    @Autowired
    INewsClient iNewsClient;

    /**
     * 查询文章列表和作者
     *
     * @return
     */
    @PostMapping("/list_vo")
    public ResponseResult listVo(@RequestBody NewsListDto dto) {
        return iNewsClient.listVo(dto);
    }

    /**
     * 根据id查询文章详情和作者
     * @param id
     * @return
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult getOneById(@PathVariable Long id) {
        return iNewsClient.getOneById(id);
    }

    /**
     * 审核失败
     * @param dto
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsListDto dto) {
        return iNewsClient.authFail(dto);
    }

    /**
     * 审核成功
     * @param dto
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsListDto dto) {
        return iNewsClient.authPass(dto);
    }
}
